var countPrimeSetBits = function (left, right) {
  var num = 0;
  for (var x = left;x <= right;++x) {
    var valueNum = get(x)
    num += is(valueNum)
  }
  return num;
};

function get (value) {
  var valueNum = 0
  for (;value > 0;value = parseInt(value / 2)) {
    if (value % 2 === 1) valueNum++
  }
  return valueNum
}

function is (valueNum) {
  var num = 0
  for (var i = valueNum - 1;i > 0;i--) {
    if (i === 1) num++
    if (valueNum % i === 0) break
  }
  return num
}

console.log(countPrimeSetBits(6, 10));